<?php
namespace Admin\Controller;
use Admin\Controller\BaseController;
class MessagesController extends BaseController {
	private $tbl;
	public function _initialize(){
		$this->tbl='messages';
		$this->model=D($this->tbl);
		parent::_initialize();
	}
    public function index(){
		$sql="select * from yjl_messages inner join yjl_users inner join yjl_goods on yjl_users.yjl_id=yjl_messages.yjl_uid and yjl_goods.yjl_id=yjl_messages.yjl_gid";
		$res=M()->query($sql);
		$this->assign("list",$res);
		$this->display();
		
    }
	public function	view(){
		$id=I('get.id');//获取id
	}
	public function delete(){//删除
		parent::delete($this->tbl,"yjl_id","yjl_pic");
	}
	public function search(){
		$key=I('post.searchname');
		$sql="select * from yjl_messages inner join yjl_users inner join yjl_goods on yjl_users.yjl_id=yjl_messages.yjl_uid and yjl_goods.yjl_id=yjl_messages.yjl_gid
		 where yjl_messages.yjl_content like '%".$key."%' or yjl_users.yjl_username like '%".$key."%' or yjl_goods.yjl_name like '%".$key."%'";
		$res=M()->query($sql);
		$this->assign("list",$res);
		$this->display();
	}
}